package com.example.environment.controller;

import com.example.environment.pojo.Supervisor;
import com.example.environment.service.SupervisorService;
import com.example.environment.tools.common.ResultMsg;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.UUID;

@RestController
@RequestMapping("/supervisor")
public class SupervisorController {
    @Autowired
    private SupervisorService supervisorService;

    @GetMapping("/getAllSupervisor")
    public ResultMsg getAllSupervisors() {
        return ResultMsg.successOp(supervisorService.list());
    }

    @GetMapping("/addSupervisor")
    public ResultMsg addSupervisor(Supervisor supervisor) {
        supervisor.setId(UUID.randomUUID().toString());
        System.out.println(supervisor);
        return supervisorService.saveByUnique(supervisor);
    }

}
